package com.my.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.my.annotation.SystemOperatorLog;
import com.my.common.CommonBusiLogic;
import com.my.common.MyLogger;
import com.my.dao.LeaveBillMapperExt;
import com.my.entity.LeaveBill;
import com.my.entity.Page;
import com.my.entity.ResponseData;
import com.my.entity.vo.LeaveBillVo;
import com.my.service.LeaveBillService;

@Service
public class LeaveBillServiceImpl extends MyLogger<LeaveBillServiceImpl> implements LeaveBillService {
	private static final Logger logger = LoggerFactory.getLogger(LeaveBillServiceImpl.class);

	@Resource
	private LeaveBillMapperExt leaveBillMapperExt;
	
	@Override
	public int deleteByPrimaryKey(Long id) {
		return leaveBillMapperExt.deleteByPrimaryKey(id);
	}

	@Override
	public int insertSelective(LeaveBill record) {
		return leaveBillMapperExt.insertSelective(record);
	}

	@Override
	public LeaveBill selectByPrimaryKey(Long id) {
		return leaveBillMapperExt.selectByPrimaryKey(id);
	}

	@Override
	public int updateByPrimaryKeySelective(LeaveBill record) {
		logger.info("修改请假信息");
		return leaveBillMapperExt.updateByPrimaryKeySelective(record);
	}
	
	@Override
	public List<LeaveBillVo> queryByUserId(Long id) {
		return leaveBillMapperExt.queryByUserId(id);
	}
	
	@Override
	public ResponseData<LeaveBillVo> queryByUserIdForPage(Long userId, Page page,String leaveDate,String empName) {
		if(null==page || page.getCurrent()==0 || page.getLength()==0){
			page=new Page();
			page.setCurrent(1);
			page.setLength(10);
		}
		page = CommonBusiLogic.setPageBeginByPage(page);
		List<LeaveBillVo> data=leaveBillMapperExt.queryByUserIdForPage(userId, page,leaveDate,empName);
		int count=leaveBillMapperExt.countQueryByUserIdForPage(userId,leaveDate,empName);
		ResponseData<LeaveBillVo> responseData=new ResponseData<LeaveBillVo>(data, count);
		return responseData;
	}

	@Override
	public int countQueryByUserIdForPage(Long userId, String leaveDate,
			String empName) {
		return leaveBillMapperExt.countQueryByUserIdForPage(userId, leaveDate, empName);
	}
	
	@Override
	public LeaveBillVo selectByPrimaryKeyVo(Long id) {
		return leaveBillMapperExt.selectByPrimaryKeyVo(id);
	}

}
